local nq=4

*************************************************************************************
*************************************************************************************
*************************************************************************************
// BUNCHING PLOT 
*************************************************************************************
*************************************************************************************
*************************************************************************************
use "$datapath/001_nlsy_child_mother_cog.dta", clear
drop if hours==2080
keep if hours<=2500
local rhs = "hours"
xtile Q`nq'_afqt = afqt_mom, nq(`nq')
sort `rhs'
cumul `rhs', generate(CDF_`rhs')
forvalues q=1(1)`nq' {
	cumul `rhs' if Q`nq'_afqt==`q', generate(CDF_`rhs'_q`q')
}
label variable CDF_`rhs' "All Sample"			
label variable CDF_`rhs'_q1 "Quartile 1"
label variable CDF_`rhs'_q2 "Quartile 2"
label variable CDF_`rhs'_q3 "Quartile 3"	
label variable CDF_`rhs'_q4 "Quartile 4"	


twoway 	(line CDF_`rhs'_q1 `rhs', lcolor(black) lpattern(shortdash)) ///
		(line CDF_`rhs'_q2 `rhs', lcolor(black) lpattern(dot)) ///
		(line CDF_`rhs'_q3 `rhs', lcolor(black) lpattern(dash)) ///
		(line CDF_`rhs'_q4 `rhs', lcolor(black) lpattern(solid)), scheme(s1mono) ///
		xtitle("Average hours per year working during three first years of child") ///
		ytitle("CDF")
graph export "$figpath/002_BunchingCDF_`rhs'_AFQT.pdf", replace
